<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateUser extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('user',array('engine'=>'InnoDb','collation'=>'utf8mb4_general_ci'));
        $table->addColumn('wx_unid', 'string',array('limit'  =>  300,'default'=>'','comment'=>'微信unid'))
            ->addColumn('name', 'string',array('limit'  =>  150,'default'=>'','comment'=>'用户名称'))
            ->addColumn('phone', 'string',array('limit'  =>  11,'default'=>'','comment'=>'用户绑定手机号'))
            ->addColumn('password', 'string',array('limit'  =>  32,'default'=>'','comment'=>'用户密码'))
            ->addColumn('salt', 'string',array('limit'  =>  32,'default'=>'','comment'=>'密码盐'))
            ->addColumn('douyin', 'string',array('limit'  =>  300,'default'=>'','comment'=>'用户绑定抖音号'))
            ->addColumn('author_id', 'string',array('limit'  =>  300,'default'=>'','comment'=>'达人id'))
            ->addColumn('token', 'string',array('limit'  =>  500,'default'=>'','comment'=>''))
            ->addColumn('status', 'boolean',array('limit'  =>  1,'default'=>1,'comment'=>'用户状态1为正常，2为禁用'))
            ->addColumn('create_time', 'integer',array('limit'  =>  11,'default'=>0,'comment'=>'用户创建时间'))
            ->addColumn('update_time', 'integer',array('limit'  =>  11,'default'=>0,'comment'=>'用户更新时间'))
            ->addIndex(array('wx_unid'))
            ->addIndex(array('douyin'))
            ->create();
    }
}
